package akka.in.action
import com.typesafe.config._
import akka.actor._
/**
  * Created by shichen on 2017/6/15.
  */
object ch06_frontendActor extends App{
  val conf =
    """
      |akka {
      |  actor {
      |    provider = "akka.remote.RemoteActorRefProvider"
      |  }
      |
      |  remote {
      |    enabled-transports = ["akka.remote.netty.tcp"]
      |    netty.tcp {
      |      hostname = "0.0.0.0"
      |      port = 2552
      |    }
      |  }
      |}
    """.stripMargin
  //println(conf)
  val config = ConfigFactory.parseString(conf)
  val frontend = ActorSystem("frontend",config)

  //won't report error when path format is not correct !!!
  val path = "akka.tcp://backend@0.0.0.0:2551/user/simple"
  val simple = frontend.actorSelection(path)
  while (true) {
    simple ! "hello,world"
    Thread.sleep(1000)
  }

}
